﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Web.Mvc;

namespace Presentation.Web.Admin
{
    public class PreAdminEngine
    {
        /// <summary>
        /// Resolves this instance.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T Resolve<T>() where T : class
        {
            var res = DependencyResolver.Current.GetService<T>();
            return res;
        }

        /// <summary>
        /// Resolves the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public static object Resolve(Type type)
        {
            var res = DependencyResolver.Current.GetService(type);
            return res;
        }

        public static IEnumerable<object> ResolveAll(Type type)
        {
            var res = DependencyResolver.Current.GetServices(type);
            return res;
        }

        /// <summary>
        /// Resolves all.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public static IEnumerable<T> ResolveAll<T>()
        {
            var res = DependencyResolver.Current.GetServices<T>();
            return res;
        }
    }
}